package com.itheima.netmarket.factory;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import com.itheima.netmarket.formwork.engin.JsonEngin;

/**
 * 
 * @author 武嘉豪
 * 
 */
public class EnginFactory {
	/**
	 * 
	 * @param name
	 *            需要得到实现类的接口的名称
	 * @return 根据名称得到的实现类
	 */
	public static JsonEngin getEngin(String name) {
		Properties prop = new Properties();
		try {
			prop.load(EnginFactory.class.getClassLoader().getResourceAsStream("FactoryProperties.properties"));
			Class<JsonEngin> clazz = (Class<JsonEngin>) Class.forName(prop.getProperty(name));
			return clazz.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
